package com.cm.projectx.common.config;

import com.cm.projectx.common.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private UserInterceptor userInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInterceptor)
                .addPathPatterns("/v2api/**") // 更具体的API路径
                .excludePathPatterns(
                        "/api/public/**",
                        "/error", // 排除错误页面
                        "/static/**", // 排除静态资源
                        "/webjars/**" // 排除webjars
                );
    }
}